package com.wicket.okrbff.plugin.config;

import com.wicket.okrbff.plugin.interceptor.AuthInterceptor;
import com.wicket.okrbff.plugin.interceptor.CommonInterceptor;
import com.wicket.okrbff.plugin.interceptor.SpecInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * @author ：CHS
 * @since 2022/3/29 17:24
 *
 *
 * @version 1.0
 */
@Configuration
public class CustomWebMvcConfigurer implements WebMvcConfigurer {

    @Bean
    public AuthInterceptor myInterceptor() {
        return new AuthInterceptor();
    }

    @Bean
    public CommonInterceptor myInterceptor2() {
        return new CommonInterceptor();
    }
    @Bean
    public SpecInterceptor myInterceptor3() {
        return new SpecInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(myInterceptor()).addPathPatterns("/**")
                .excludePathPatterns(
                        "/oms/intelligentCommunication/implementSmartSession",
                        "/oms/base/chat",
                        "/oms/security/addStandardDetermineTenantCertificateAvailabilityAbnormalCom",
                        "/oms/user/implementThirdPartyLoginOut","/oms/base/querySpaceAppDetailCom",
                        "/login",
                        "/oms/user/queryObtainUnifiedAuthenticationLoginInformationDetail",
                        "/oms/user/login",
                        "/oms/user/logUserIn",
                        "/oms/user/implementLogin",
                        "/oms/password/updateForgotPassword",
                        "/oms/user/queryUserPwdProblemDetail",
                        "/oms/common/setpublicinfo",
                        "/swagger-resources/**",
                        "/webjars/**",
                        "/v2/**",
                        "/swagger-ui.html/**",
                        "/api",
                        "/api-docs",
                        "/api-docs/**",
                        "/doc.html/**",
                        "/error",
                        "/favicon.ico"
                );

        registry.addInterceptor(myInterceptor2()).addPathPatterns("/oms/intelligentCommunication/implementSmartSession","/oms/user/implementThirdPartyLoginOut","/oms/base/querySpaceAppDetailCom", "/login", "/oms/user/queryObtainUnifiedAuthenticationLoginInformationDetail", "/oms/user/login","/oms/user/logUserIn","/oms/password/updateForgotPassword","/oms/user/queryUserPwdProblemDetail")
                .excludePathPatterns("/oms/user/implementLogin");

        registry.addInterceptor(myInterceptor3());
    }

}
